import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: '电子奖状 - 登录'
    },
    component: () => import('@/views/login.vue')
};

export const loginMemberRouter = {
    path: '/loginMember',
    name: 'loginMember',
    meta: {
        title: '电子奖状 - 会员登录'
    },
    component: () => import('@/views/loginMember.vue')
};

export const memberPrizesRouter = {
    path: '/memberprizes',
    name: 'memberprizes',
    meta: {
        title: '我的奖状'
    },
    component: () => import('@/views/memberprizes/memberprizes.vue')
};

export const registerRouter = {
    path: '/register',
    name: 'register',
    meta: {
        title: '注册'
    },
    component: () => import('@/views/register/register.vue')
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: () => import('@//views/error-page/403.vue')
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: () => import('@/views/error-page/500.vue')
};

export const preview = {
    path: '/preview',
    name: 'preview',
    component: () => import('@/views/form/article-publish/preview.vue')
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: () => import('@/views/main-components/lockscreen/components/locking-page.vue')
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/user',
    component: Main,
    children: [
        { path: 'home', title: {i18n: 'home'}, name: 'home_index', component: () => import('@/views/home/home.vue') },
        { path: 'ownspace', title: '个人中心', name: 'ownspace_index', component: () => import('@/views/own-space/own-space.vue') },
        { path: 'order/:order_id', title: '订单详情', name: 'order-info', component: () => import('@/views/advanced-router/component/order-info.vue') }, // 用于展示动态路由
        { path: 'shopping', title: '购物详情', name: 'shopping', component: () => import('@/views/advanced-router/component/shopping-info.vue') }, // 用于展示带参路由
        { path: 'message', title: '消息中心', name: 'message_index', component: () => import('@/views/message/message.vue') }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
/*import User from '@/views/user/user.vue';
import Award from '@/views/award/award.vue';*/
export const appRouter = [
    {
        path: '/data',
        icon: 'soup-can',
        name: 'data',
        title: '数据中心',
        component: Main,
        access: 1,
        children: [{
            path: 'organize',
            title: '机构中心',
            name: 'organize',
            component: () => import('@/views/register/audit/audit.vue')
        }, {
            path: 'member',
            title: '会员中心',
            name: 'member',
            component: () => import('@/views/member/member.vue')
        }, {
            path: 'prizeallot',
            title: '奖状中心',
            name: 'prizeallot',
            component: () => import('@/views/prizeAllot/prizeAllot.vue')
        }, {
            path: 'charge',
            title: '收费管理',
            name: 'charge',
            component: () => import('@/views/charge/charge.vue')
        }, {
            path: 'info',
            title: '信息发布',
            name: 'info',
            component: () => import('@/views/info/info.vue')
        }]
    },{
        path: '/resource',
        icon: 'folder',
        name: 'resource',
        title: '资源管理',
        component: Main,
        access: 1,
        children: [{
            path: 'background',
            title: '背景管理',
            name: 'background',
            component: () => import('@/views/background/background.vue')
        }, {
            path: 'chapter',
            title: '章管理',
            name: 'chapter',
            component: () => import('@/views/chapter/chapter.vue')
        }, {
            path: 'prizemodel',
            title: '模板管理',
            name: 'prizemodel',
            component: () => import('@/views/prizemodel/prizemodel.vue')
        }, {
            path: 'prizemodelmake',
            title: '模板制作',
            name: 'prizemodelmake',
            component: () => import('@/views/prizemodel/make/make.vue')
        }]
    },{
        path: '/prizes',
        icon: 'trophy',
        name: 'prizes',
        title: '奖状管理',
        component: Main,
        access: 1,
        children: [{
            path: 'theme',
            title: '主题管理',
            name: 'theme',
            component: () => import('@/views/theme/theme.vue')
        }, {
            path: 'prize',
            title: '奖状生成',
            name: 'prize',
            component: () => import('@/views/prize/prize.vue')
        }, {
            path: 'prizeAppeal',
            title: '奖状申诉',
            name: 'prizeAppeal',
            component: () => import('@/views/prizeAppeal/appeal.vue')
        }]
    },{
        path: '/setup',
        icon: 'gear-b',
        name: 'setup',
        title: '基础设置',
        component: Main,
        access: 1,
        children: [{
            path: 'level',
            title: '级别定义',
            name: 'level',
            component: () => import('@/views/level/level.vue')
        }, {
            path: 'user',
            title: '用户管理',
            name: 'user',
            component: () => import('@/views/user/user.vue')
        }, {
            path: 'role',
            title: '角色管理',
            name: 'role',
            component: () => import('@/views/role/role.vue')
        }, {
            path: 'dictionary',
            title: '数据字典',
            name: 'dictionary',
            component: () => import('@/views/dictionary/dictionary.vue')
        }]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    registerRouter,
    loginMemberRouter,
    memberPrizesRouter,
    otherRouter,
    preview,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];
